// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import echarts from 'echarts'

Vue.prototype.$echarts = echarts


axios.defaults.baseURL="http://localhost:8080"
axios.defaults.withCredentials=true

Vue.prototype.$http=axios

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)


Vue.config.productionTip = false


axios.interceptors.response.use(resp=>{
				if(resp.data.code==403) {
          localStorage.removeItem("com.woniu.loginUser")
          router.replace("/login")
				}
				return resp;
			})


router.beforeEach((to,from,next)=>{
  if(to.path=="/login"||to.path=="/regist"){
    next();
  }else{
    if(localStorage.getItem("com.woniu.loginUser")!=null){
      next()
    }else{
      next("/login")
    }
  }
})

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
